//
//  NSArray-Extension.swift
//  Whiteboard
//
//  Created by point on 2018/1/9.
//  Copyright © 2018年 point. All rights reserved.
//

import UIKit

extension NSArray {
    /** 配置数据 */
    func configDictOutPutInt( num:Int) -> Int {
        for (i , dict) in self.enumerated() {
            let dict:Dictionary = dict as! Dictionary<String, String>
            
            if i == self.count - 1 {
                guard dict["neverMax"] != nil else {
                    print("配置出错")
                    return 0
                }
                let val = Int(dict["val"]!)!
                let neverMax = Int(dict["neverMax"]!)!
                if num >= neverMax {
                    return val
                }else {
                    print("未找到的数据")
                }
                
            }else {
                guard dict["min"] != nil else {
                    print("min配置出错")
                    return 0
                }
                guard dict["max"] != nil else {
                    print("max配置出错")
                    return 0
                }
                
                let min = Int(dict["min"]!)!
                let max = Int(dict["max"]!)!
                let val = Int(dict["val"]!)!
                if (min <= num && num <= max ) {
                    return val
                }
            }
        }
        return 0
    }
}
